<?php
class Pageley_Commerce_AddInfoToOrderTests extends Pageley_Commerce_DomainTests {

    public function testAddInfoToOrder() {
        $success = $this->dispatchRequest(array(
            "controller" => "Commerce/LogInCustomer",
            "username" => "bill.gates",
            "password" => "irock"
        ));
        $this->assertTrue($success);
        $success = $this->dispatchRequest(array(
            "controller" => "Commerce/AddItemToOrder",
            "articleId" => "1",
            "quantity" => "2"
        ));
        $this->assertTrue($success);
        $success = $this->dispatchRequest(array(
            "controller" => "Commerce/AddInfoToOrder",
            "paymentMethod" => "TRANSFER",
            "comment" => "test comment",
            "sendInvoice" => "1",
            "billingName" => "Bill Gates",
            "billingAddress.line1" => "1, Test Street",
            "billingAddress.postalCode" => "123456",
            "billingAddress.city" => "Test City",
            "billingEmailAddress" => "bill.gates@hotmail.com",
            "deliveryName" => "Bill Gates",
            "deliveryAddress.line1" => "1, Test Street",
            "deliveryAddress.postalCode" => "123456",
            "deliveryAddress.city" => "Test City"
        ));
        $this->assertTrue($success);
        $factory = Pageley_Controller_Session_Factory::getInstance();
        $session = $factory->getSession();
        $order = $session->get("commerce.order");
        $this->assertNotNull($order);
        $this->assertEquals(Pageley_Commerce_Domain_PaymentMethod::$TRANSFER, $order->get("paymentMethod"));
        $this->assertTrue($order->get("sendInvoice"));
        $this->assertNotNull($order->get("billingAddress"));
        $this->assertEquals("123456", $order->get("billingAddress")->get("postalCode"));

    }

}